Service Manager

Home 

Examples of Processing Emails Received in XML Format

Example 1: Importing a Single Email

Example 2: Importing Incidents and Service Requests into the Same Inbox

Example 1: Importing a Single Email

This example includes the following:

An example of an email sent by a customer. See below:

<INCIDENT>

<DESCRIPTION>xml email processing</DESCRIPTION>

<SERVICE>Desktop Service</SERVICE>

<CATEGORY>Performance Issue</CATEGORY>

<OWNER>Quality Assurance</OWNER>

<OWNERTEAM>IT</OWNERTEAM>

<URGENCY>Medium</URGENCY>

<IMPACT>Medium</IMPACT>

<SOURCE>Email</SOURCE>

<PROFILELINK>Kelly Yao</PROFILELINK>

</INCIDENT>

An example of an XML file that is generated from the original email, but is not in the hierarchical XML format. Go to Ex1-Import-Generated-Email.xml to see the file.

An example of an XSLT file to apply to it. Go to Ex1-Import-Script.xslt to see the file.

An example of the final XML file after applying the XSLT file to it. Go to Ex1-Import-Final-Email.xml to see an example of the final XML file after applying the XSLT file to it.

Example 2: Importing Incidents and Service Requests into the Same Inbox

This example shows how to import incidents and service requests into the same inbox and contains the following:

An example of an email sent by a customer to import an incident and an example of an email sent by a customer to import a service request.

Example of an email sent by a customer to import an incident:

<INCIDENT>

<DESCRIPTION>Test XML </DESCRIPTION>

<SERVICE>Desktop Service</SERVICE>

<CATEGORY>Performance Issue</CATEGORY>

<OWNERTEAM>Operations</OWNERTEAM>

<OWNER>Administrator Admin</OWNER>

<URGENCY>Medium</URGENCY>

<IMPACT>Medium</IMPACT>

<SOURCE>Email</SOURCE>

<PROFILELINK>Administrator Admin</PROFILELINK>

</INCIDENT>

Example of an email sent by a customer to import a service request:

Department$IT

Requester$Alan Taylor

[email protected]

An example of an XML file that is generated from the original email, but is not in the hierarchical XML format. Go to Ex2-Import-Generated-Email.xml to see an example of a generated XML email file to import an incident and go to Ex2-Import-Generated-Email2.xml to see an example of a generated XML email file to import a service request.

An example of an XSLT file to apply to it.  Go to Ex2-Import-Script3.xslt to see an example of an XSLT file to import both an incident and a service request, go to Ex2-Import-Script.xslt to see an example of an XSL file to import an incident, or go to Ex2-Import-Script2.xsl to see an example of an XSL file to import a service request.

An example of the final XML file after applying the XSLT file to it, for importing an incident (go to Ex2-Import-Final-Email.xml to see an example of the final XML file after applying the XSL and XSLT files to it) or for importing a service request ( go to Ex2-Import-Final-Email2.xml to see an example of the final XML file after applying the XSL and XSLT files to it).

Ex1-Import-Generated-Email.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0">

<BusinessObject Name="">

<EmailMessage>

<MessageID>a6354f29-4771-4095-a6d4-e5c8d318ea8e</MessageID>

<From>[email protected]</From>

<Header>Return-Path: <[email protected]> Delivered-To: [email protected] Received: from smtp28.gate.ord1a (smtp28.gate.ord1a.rsapps.net [10.130.4.28]) by store114a.mail.ord1b (SMTP Server) with ESMTP id A631D1700BB for <[email protected]>; Tue, 10 Feb 2015 16:59:44 -0500 (EST) X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-0-0-6469-c X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.1 cv=cbzr8BzM c=1 sm=0 tr=0 a=LsHV51zzIncP4I3293WPhQ==:117 a=LsHV51zzIncP4I3293WPhQ==:17 a=3hggNd4wljYA:10 a=8kQvQK_AAAAA:8 a=-jBlUN_C1od1TIktrMEA:9 a=CjuIK1q_8ugA:10 a=y8dZ710oujAA:10 a=ZG0p_6W2l6MA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=vZHfknC3XJGfoCVC:21 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 X-Orig-To: [email protected] X-Originating-Ip: [206.104.144.248] Received: from [206.104.144.248] ([206.104.144.248:7847] helo=mx.frontrange.com) by smtp28.gate.ord1a.rsapps.net (envelope-from <[email protected]>) (ecelerity 2.2.3.49 r(42060/42061)) with ESMTPS (cipher=AES128-SHA) id 87/E6-07842-05F7AD45; Tue, 10 Feb 2015 16:59:44 -0500 From: Kelly Yao <[email protected]> To: "[email protected]" <[email protected]> Subject: RE: test xml email 2 Thread-Topic: test xml email 2 Thread-Index: AdBFfNwNr8mS8AqRR+if/GWc7ATR2w== Date: Tue, 10 Feb 2015 21:59:42 +0000 Message-ID: <[email protected]> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_000_31AC186C71B83241A869D7FDEBCDE12928BF3438CSMBX03nafrs_" MIME-Version: 1.0</Header>

<ReplyTo/>

<Sender/>

<To>[email protected]</To>

<CC/>

<BCC/>

<TimeStamp>02/10/2015 21:59:42</TimeStamp>

<BlockCount>0</BlockCount>

<Subject>RE: test xml email 2</Subject>

<SubjectID/>

<Body><INCIDENT> <DESCRIPTION>xml email processing</DESCRIPTION> <SERVICE>Desktop Service</SERVICE> <CATEGORY>Performance Issue</CATEGORY> <OWNER>Quality Assurance</OWNER> <OWNERTEAM>IT</OWNERTEAM> <URGENCY>Medium</URGENCY> <IMPACT>Medium</IMPACT> <SOURCE>Email</SOURCE> <PROFILELINK>Kelly Yao</PROFILELINK> </INCIDENT></Body>

<BodyHTML><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <meta name="Generator" content="Microsoft Word 14 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:LucidaConsole; panose-1:0 0 0 0 0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:windowtext;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--> </head> <body lang="EN-US" link="blue" vlink="purple"> <div class="WordSection1"> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;INCIDENT&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;DESCRIPTION&gt;xml email processing&lt;/DESCRIPTION&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;SERVICE&gt;Desktop Service&lt;/SERVICE&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;CATEGORY&gt;Performance Issue&lt;/CATEGORY&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;OWNER&gt;Quality Assurance&lt;/OWNER&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;OWNERTEAM&gt;IT&lt;/OWNERTEAM&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;URGENCY&gt;Medium&lt;/URGENCY&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;IMPACT&gt;Medium&lt;/IMPACT&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;SOURCE&gt;Email&lt;/SOURCE&gt;<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;PROFILELINK&gt;Kelly Yao&lt;/PROFILELINK&gt;<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size:10.0pt;font-family:LucidaConsole;color:#B32222">&lt;/INCIDENT&gt;</span><o:p></o:p></p> </div> </body> </html></BodyHTML>

</EmailMessage>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Employee">

<Transaction>None</Transaction>

<LinkTransaction>None</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="PrimaryEmail"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">74142674F0E947849A940FDCCA63B501/>Field>

<Field Name="PrimaryEmail">[email protected]</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Journal.Email">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">C712701E07F94B00A40CE48F97C8511F</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

 

Ex1-Import-Script.xslt

<?xml version="1.0" encoding="UTF-8"?>

<!--

This XSLT sample will convert the following email body in XML format generated by the email service to hierarchical XML that can be consumed by the integration server using schema version "1.0".

 

<INCIDENT>

<DESCRIPTION>PC is very slow</DESCRIPTION>

<SERVICE>Desktop Service</SERVICE>

<CATEGORY>Performance Issue</CATEGORY>

<OWNER>Quality Assurance</OWNER>

<OWNERTEAM>IT</OWNERTEAM>

<URGENCY>Medium</URGENCY>

<IMPACT>Medium</IMPACT>

<SOURCE>Email</SOURCE>

</INCIDENT>

-->

 

<xsl:stylesheet version="2.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:user="urn:schemas-microsoft-com:xslt">

<xsl:variable name="ebody"/>

<!-- Transform to XML fragment -->

<xsl:variable name="params"select="msxsl:node-set($ebody)/tag[@name='INCIDENT']/tag"/>

<xsl:template match="/">

<BusinessObjectList SchemaVersion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd">

<!-- Find the profile link RecID of the email sender -->

<xsl:variable name="profilelink_recid">

<!-- For each related business object -->

<xsl:for-each select="BusinessObjectList/BusinessObject/RelatedBusinessObjectList/RelatedBusinessObject/BusinessObject">

<xsl:choose>

<xsl:when test="@Name = 'Employee'">

<xsl:for-each select="./FieldList/Field">

<xsl:choose>

<xsl:when test="@Name = 'RecId'">

<xsl:value-of select="."/>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:variable>

<!-- Find the profile link category of the email sender -->

<xsl:variable name="profilelink_cat">

<!-- For each RelatedBusinessObject -->

<xsl:for-each select="BusinessObjectList/BusinessObject/RelatedBusinessObjectList/RelatedBusinessObject/BusinessObject">

<xsl:choose>

<xsl:when test="@Name = 'Employee'">

<xsl:value-of select="'Employee'"/>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:variable>

<!-- For each business object -->

<xsl:for-each select="BusinessObjectList/BusinessObject">

<!-- Set the business object name -->

<xsl:element name="BusinessObject">

<!-- Set the business object name to 'Incident' -->

<xsl:attribute name="Name">

<xsl:value-of select="'Incident'"/>

</xsl:attribute>

<!-- Set transaction to 'Insert' -->

<xsl:element name="Transaction">Insert</xsl:element>

<!--Unique key list-->

<xsl:element name="UniqueKeyList">

<xsl:element name="UniqueKey">

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:value-of select="'IncidentNumber'"/></xsl:attribute>

</xsl:element>

</xsl:element>

</xsl:element>

<!-- Field list -->

<FieldList>

<!-- Fields -->

<xsl:for-each select="EmailMessage/node()">

<xsl:choose>

<xsl:when test="name() = 'Subject'">

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:value-of select="'Subject'"/>

</xsl:attribute>

<xsl:attribute name="Type">System.String</xsl:attribute>

<xsl:value-of select="."/>

</xsl:element>

</xsl:when>

<xsl:when test="name() = 'Body'">

<xsl:variable name="emailbody">

<xsl:choose>

<xsl:when test="starts-with(normalize-space(.), '&lt;INCIDENT&gt;')">

<xsl:call-template name="StringToXML">

<!-- Remove CRLF -->

<xsl:with-param name="text" select="translate(., '&#xA;', '')"/>

</xsl:call-template>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="'Email body does not contain XML for Incident'"/>

</xsl:otherwise>

</xsl:choose>

</xsl:variable>

<!-- Transform to XML fragment -->

<xsl:variable name="parameters" select="msxsl:node-set($emailbody)/tag[@name='INCIDENT']/tag"/>

<xsl:variable name="symptom"select="$parameters[@name='DESCRIPTION']/text()"/>

<xsl:variable name="service"select="$parameters[@name='SERVICE']/text()"/>

<xsl:variable name="category"select="$parameters[@name='CATEGORY']/text()"/>

 

<xsl:variable name="owner"select="$parameters[@name='OWNER']/text()"/>

<xsl:variable name="ownerteam" select="$parameters[@name='OWNERTEAM']/text()"/>

 

<xsl:variable name="impact"select="$parameters[@name='IMPACT']/text()"/>

<xsl:variable name="urgency"select="$parameters[@name='URGENCY']/text()"/>

<xsl:variable name="source"select="$parameters[@name='SOURCE']/text()"/>

 

<!-- Symptom -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Symptom</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($symptom) > 0">

<xsl:value-of select="$symptom"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Default Symptom goes here</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Service -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Service</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($service) > 0">

<xsl:value-of select="$service"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Service Desk</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Category -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Category</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($category) > 0">

<xsl:value-of select="$category"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Service Desk</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Owner -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Owner</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($owner) > 0">

<xsl:value-of select="$owner"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Admin</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Owner team -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>OwnerTeam</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($ownerteam) > 0">

<xsl:value-of select="$ownerteam"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Service Desk</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Impact -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Impact</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($impact) > 0">

<xsl:value-of select="$impact"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>2</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Urgency -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Urgency</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($urgency) > 0">

<xsl:value-of select="$urgency"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>2</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Source -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>Source</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($source) > 0">

<xsl:value-of select="$source"/>

</xsl:when>

<xsl:otherwise>

<xsl:text>Email</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Profile link category -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>ProfileLink_Category</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($profilelink_cat) > 0">

<xsl:value-of select="$profilelink_cat"/>

</xsl:when>

<xsl:otherwise>

<!-- Set as 'Employee' -->

<xsl:text>Employee</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

<!-- Profile link RecID -->

<xsl:element name="Field">

<xsl:attribute name="Name">

<xsl:text>ProfileLink_RecID</xsl:text>

</xsl:attribute>

<xsl:choose>

<xsl:when test="string-length($profilelink_recid) > 0">

<xsl:value-of select="$profilelink_recid"/>

</xsl:when>

<xsl:otherwise>

<!-- Set as admin RecID-->

<xsl:text>FB884D18F7B746A0992880F2DFFE749C</xsl:text>

</xsl:otherwise>

</xsl:choose>

</xsl:element>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</FieldList>

<!-- Copy the RelatedBusinessObjectList element-->

<RelatedBusinessObjectList>

<xsl:for-each select="RelatedBusinessObjectList/RelatedBusinessObject">

<xsl:element name="RelatedBusinessObject">

<xsl:attribute name="Relationship">

<xsl:choose>

<xsl:when test="BusinessObject/@Name = 'Employee'">

<xsl:value-of select="'IncidentOwnerEmployee'"/>

</xsl:when>

<xsl:when test="BusinessObject/@Name = 'Journal.Email'">

<xsl:value-of select="'IncidentContainsJournal'"/>

</xsl:when>

</xsl:choose>

</xsl:attribute>

<xsl:copy-of select="node()"/>

</xsl:element>

</xsl:for-each>

</RelatedBusinessObjectList>

 

</xsl:element>

</xsl:for-each>

</BusinessObjectList>

</xsl:template>

<xsl:template name="StringToXML">

<xsl:param name="text"/>

<xsl:choose>

<!-- Check if $text is an XML fragment -->

<xsl:when test="contains($text, '&lt;')">

<xsl:variable name="tmp1" select="substring-after($text, '&lt;')"/>

<xsl:variable name="tmp2" select="substring-after($tmp1, '&gt;')"/>

<xsl:variable name="tagName" select="substring-before($tmp1, '&gt;')"/>

<xsl:variable name="endTag" select="concat(concat('&lt;', concat('/', $tagName)), '&gt;')"/>

<xsl:value-of select="substring-before($text, '&lt;')"/>

<!-- Create the tag -->

<xsl:element name="tag">

<xsl:attribute name="name">

<xsl:value-of select="translate($tagName, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>

</xsl:attribute>

<!-- Create the children tree -->

<xsl:call-template name="StringToXML">

<xsl:with-param name="text" select="substring-before($tmp2, $endTag)"/>

</xsl:call-template>

</xsl:element>

<!-- Create the following siblings tree -->

<xsl:call-template name="StringToXML">

<xsl:with-param name="text" select="substring-after($tmp2, $endTag)"/>

</xsl:call-template>

</xsl:when>

<!-- $text is not an XML fragment, so just print the text itself-->

<xsl:otherwise>

<xsl:choose>

<xsl:when test="$text !=''">

<xsl:value-of select="$text"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="'Invalid XML. Empty string'"/>

</xsl:otherwise>

</xsl:choose>

</xsl:otherwise>

</xsl:choose>

</xsl:template>

</xsl:stylesheet>

Ex1-Import-Final-Email.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" SchemaVersion="1.0">

<BusinessObject Name="Incident">

<Transaction>Insert</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="Subject" Type="System.String">RE: test xml email 2</Field>

<Field Name="Symptom">xml email processing</Field>

<Field Name="Service">Desktop Service</Field>

<Field Name="Category">Performance Issue</Field>

<Field Name="Owner">Quality Assurance</Field>

<Field Name="OwnerTeam">IT</Field>

<Field Name="Impact">Medium</Field>

<Field Name="Urgency">Medium</Field>

<Field Name="Source">Email</Field>

<Field Name="ProfileLink_Category">Employee</Field>

<Field Name="ProfileLink_RecID">74142674F0E947849A940FDCCA63B501</Field>

</FieldList>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="IncidentOwnerEmployee">

<BusinessObject Name="Employee">

<Transaction>None</Transaction>

<LinkTransaction>None</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="PrimaryEmail"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">74142674F0E947849A940FDCCA63B501</Field>

<Field Name="PrimaryEmail">[email protected]</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="IncidentContainsJournal">

<BusinessObject Name="Journal.Email">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">C712701E07F94B00A40CE48F97C8511F</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

Ex2-Import-Generated-Email.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0">

<BusinessObject Name="">

<EmailMessage>

<MessageID>99289f20-ceac-4c7f-93e1-b5f18068eb8f</MessageID>

<From>[email protected]</From>

<Header>Return-Path: <[email protected]> Delivered-To: [email protected] Received: from smtp42.gate.ord1c (smtp42.gate.ord1c.rsapps.net [172.28.146.42]) by store202a.mail.ord1a (SMTP Server) with ESMTP id 1AA4437000D for <[email protected]>; Mon, 20 Apr 2015 20:11:53 -0400 (EDT) X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-0-0-7144-c X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.1 cv=O6MA4nNW c=1 sm=0 tr=0 a=LsHV51zzIncP4I3293WPhQ==:117 a=LsHV51zzIncP4I3293WPhQ==:17 a=RzHtgV3JE18A:10 a=pJT6Aq2jAAAA:8 a=ndkwzLzXJv5S2N3pvSMA:9 a=CjuIK1q_8ugA:10 a=HpScuoJWMcoA:10 a=NLW3_BR1ZZwA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=LL-MDLJ3K_IVoXNy9PIA:9 a=O-B0_aSyQqhQW31Y:21 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 X-Orig-To: [email protected] X-Originating-Ip: [206.104.144.248] Received: from [206.104.144.248] ([206.104.144.248:29357] helo=mx.frontrange.com) by smtp42.gate.ord1c.rsapps.net (envelope-from <[email protected]>) (ecelerity 2.2.3.49 r(42060/42061)) with ESMTPS (cipher=AES128-SHA) id A5/AB-18970-8C595355; Mon, 20 Apr 2015 20:11:52 -0400 From: Olga Pasternak <[email protected]> To: "[email protected]" <[email protected]> Subject: RE: Test XML 3 Thread-Topic: Test XML 3 Thread-Index: AdB7x8KvLa1rCv1DRFuDEKolkLj8ng== Date: Tue, 21 Apr 2015 00:11:49 +0000 Message-ID: <[email protected]> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_000_3DC74DF0B4F8894F867A5A929A825F2D10A68604CSMBX03nafrs_" MIME-Version: 1.0</Header>

<ReplyTo/>

<Sender/>

<To>[email protected]</To>

<CC/>

<BCC/>

<TimeStamp>04/21/2015 00:11:49</TimeStamp>

<BlockCount>0</BlockCount>

<Subject>RE: Test XML 3 </Subject>

<SubjectID/>

<Body><INCIDENT> <DESCRIPTION>test XML Email </DESCRIPTION> <SERVICE>Desktop Service</SERVICE> <CATEGORY>Performance Issue</CATEGORY> <OWNERTEAM>IT</OWNERTEAM> <OWNER>Quality Assurance</OWNER> <URGENCY>Medium</URGENCY> <IMPACT>Medium</IMPACT> <SOURCE>Email</SOURCE> <PROFILELINK>Quality Assurance </PROFILELINK> </INCIDENT> </Body>

<BodyHTML><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <meta name="Generator" content="Microsoft Word 14 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} p.MsoPlainText, li.MsoPlainText, div.MsoPlainText {mso-style-priority:99; mso-style-link:"Plain Text Char"; margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} p.MsoAcetate, li.MsoAcetate, div.MsoAcetate {mso-style-priority:99; mso-style-link:"Balloon Text Char"; margin:0in; margin-bottom:.0001pt; font-size:8.0pt; font-family:"Tahoma","sans-serif";} span.PlainTextChar {mso-style-name:"Plain Text Char"; mso-style-priority:99; mso-style-link:"Plain Text"; font-family:"Calibri","sans-serif";} span.BalloonTextChar {mso-style-name:"Balloon Text Char"; mso-style-priority:99; mso-style-link:"Balloon Text"; font-family:"Tahoma","sans-serif";} span.EmailStyle21 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle22 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle23 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle24 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle25 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle26 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle27 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle28 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle29 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle30 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:8.5in 11.0in; margin:56.7pt 42.5pt 56.7pt 85.05pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--> </head> <body lang="EN-US" link="blue" vlink="purple"> <div class="WordSection1"> <p class="MsoPlainText">&lt;INCIDENT&gt;<span style="color:#1F497D"><o:p></o:p></span></p> <p class="MsoPlainText"><span style="color:#1F497D">&nbsp; </span>&lt;DESCRIPTION&gt;test <span style="color:#1F497D"> XML Email</span> &lt;/DESCRIPTION&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;SERVICE&gt;Desktop Service&lt;/SERVICE&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;CATEGORY&gt;Performance Issue&lt;/CATEGORY&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;OWNERTEAM&gt;IT&lt;/OWNERTEAM&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;OWNER&gt;Quality Assurance&lt;/OWNER&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;URGENCY&gt;Medium&lt;/URGENCY&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;IMPACT&gt;Medium&lt;/IMPACT&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;SOURCE&gt;Email&lt;/SOURCE&gt;<o:p></o:p></p> <p class="MsoPlainText">&nbsp; &lt;PROFILELINK&gt;Quality Assurance &lt;/PROFILELINK&gt; <span style="color:#1F497D"> <o:p></o:p></span></p> <p class="MsoPlainText">&lt;/INCIDENT&gt;<o:p></o:p></p> </div> </body> </html></BodyHTML>

</EmailMessage>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Employee">

<Transaction>None</Transaction>

<LinkTransaction>None</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="PrimaryEmail"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">3734B48625D043B0939456EBF5B07F43</Field>

<Field Name="PrimaryEmail">[email protected]</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Journal.Email">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">68360EB2755F4B4084E45F65FCA73162</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

Ex2-Import-Generated-Email2.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0">

<BusinessObject Name="">

<EmailMessage>

<MessageID>40d0f80d-50f5-4dc5-a468-4f861106ecdc</MessageID>

<From>[email protected]</From>

<Header>Return-Path: <[email protected]> Delivered-To: [email protected] Received: from smtp41.gate.ord1c (smtp41.gate.ord1c.rsapps.net [172.28.146.41]) by store202a.mail.ord1a (SMTP Server) with ESMTP id 5B31D37004C for <[email protected]>; Mon, 20 Apr 2015 20:17:06 -0400 (EDT) X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-0-0-4141-c X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.1 cv=ZZskaKlA c=1 sm=0 tr=0 a=LsHV51zzIncP4I3293WPhQ==:117 a=LsHV51zzIncP4I3293WPhQ==:17 a=RzHtgV3JE18A:10 a=pJT6Aq2jAAAA:8 a=Z9YDj5p0AAAA:8 a=0YBUe0dz5XustnX3RcYA:9 a=CjuIK1q_8ugA:10 a=0j5UJdqgBkUA:10 a=EIPZIosEz_EA:10 a=mItjn0crm-wA:10 a=bjFNvA4ZG3sA:10 a=fVpclg_jv2oA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=jgiXcwD34PFGoSuQ0XQA:9 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 X-Orig-To: [email protected] X-Originating-Ip: [206.104.144.248] Received: from [206.104.144.248] ([206.104.144.248:29386] helo=mx.frontrange.com) by smtp41.gate.ord1c.rsapps.net (envelope-from <[email protected]>) (ecelerity 2.2.3.49 r(42060/42061)) with ESMTPS (cipher=AES128-SHA) id B4/CD-10843-20795355; Mon, 20 Apr 2015 20:17:06 -0400 From: Olga Pasternak <[email protected]> To: "[email protected]" <[email protected]> Subject: Request - Domain Password Reset Thread-Topic: Request - Domain Password Reset Thread-Index: AdB7yFhM2NnJIEQuSfCc0VpfmBEB4g== Date: Tue, 21 Apr 2015 00:17:03 +0000 Message-ID: <[email protected]> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: multipart/alternative; boundary="_000_3DC74DF0B4F8894F867A5A929A825F2D10A68614CSMBX03nafrs_" MIME-Version: 1.0</Header>

<ReplyTo/>

<Sender/>

<To>[email protected]</To>

<CC/>

<BCC/>

<TimeStamp>04/21/2015 00:17:03</TimeStamp>

<BlockCount>0</BlockCount>

<Subject>Request - Domain Password Reset </Subject>

<SubjectID/>

<Body>Department$IT Requester$Alan Taylor [email protected] </Body>

<BodyHTML><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <meta name="Generator" content="Microsoft Word 14 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:"Calibri","sans-serif"; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri","sans-serif";} @page WordSection1 {size:8.5in 11.0in; margin:56.7pt 42.5pt 56.7pt 85.05pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--> </head> <body lang="EN-US" link="blue" vlink="purple"> <div class="WordSection1"> <p class="MsoNormal">Department$IT<o:p></o:p></p> <p class="MsoNormal">Requester$Alan Taylor<o:p></o:p></p> <p class="MsoNormal">[email protected]<o:p></o:p></p> </div> </body> </html></BodyHTML>

</EmailMessage>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Employee">

<Transaction>None</Transaction>

<LinkTransaction>None</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="PrimaryEmail"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">3734B48625D043B0939456EBF5B07F43</Field>

<Field Name="PrimaryEmail">[email protected]</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Journal.Email">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">93B33BDCFCCB45F18AC165718208420E</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

Ex2-Import-Script3.xslt

<?xml version="1.0" encoding="UTF-8"?>

<!--

This XSLT sample will convert email XML to hierarchical XML that can be consumed by the integration server using schema version "1.0" for incidents and service requests.

 

If the subject contains the term 'Request', it is assumed to be a service request of the type defined.

Otherwise it is assumed to be an incident.

-->

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:user="urn:my-scripts">

<xsl:import href="SR_import.xsl"/>

<xsl:import href="Incident_import.xsl"/>

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xsl:variable name="Subject" select = "BusinessObjectList/BusinessObject/EmailMessage/Subject"/>

<xsl:choose>

<xsl:when test="contains($Subject,'Request')">

<xsl:call-template name="SR_import"/>

</xsl:when>

<xsl:otherwise>

<xsl:call-template name="Incident_import"/>

</xsl:otherwise>

</xsl:choose>

</xsl:template>

</xsl:stylesheet>

Ex2-Import-Script.xslt

<?xml version="1.0" encoding="UTF-8"?>

<!--

This XSLT sample will convert email XML to hierarchical XML that can be consumed by the integration server using SchemaVersion "1.0" for incidents and service requests.

 

It assumes the incoming email body will be in the format:

 

<INCIDENT>

<DESCRIPTION>PC is very slow</DESCRIPTION>

<SERVICE>Desktop Service</SERVICE>

<CATEGORY>Performance Issue</CATEGORY>

<OWNER>Quality Assurance</OWNER>

<OWNERTEAM>IT</OWNERTEAM>

<URGENCY>Medium</URGENCY>

<IMPACT>Medium</IMPACT>

<SOURCE>Email</SOURCE>

</INCIDENT>

 

or

 

<REQUEST>

<TEMPLATE>Domain Password Reset</TEMPLATE>

<DESCRIPTION>PC is very slow</DESCRIPTION>

<SERVICE>Desktop Service</SERVICE>

<CATEGORY>Performance Issue</CATEGORY>

<OWNER>Quality Assurance</OWNER>

<OWNERTEAM>IT</OWNERTEAM>

<URGENCY>Medium</URGENCY>

<IMPACT>Medium</IMPACT>

<SOURCE>Email</SOURCE>

</REQUEST>

 

If the body will change, the SR_import.xsl and / or Incident_import.xsl should be changed accordingly.

-->

 

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- import xslt for: CI.Computer|CI.Server, etc -->

<xsl:import href="SR_import.xsl"/>

<xsl:import href="Incident_import.xsl"/>

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xsl:choose>

<xsl:when test="BusinessObjectList/BusinessObject/EmailMessage/Body/REQUEST">

<xsl:call-template name="SR_import"/>

</xsl:when>

<xsl:otherwise>

<xsl:call-template name="SR_import"/>

</xsl:otherwise>

</xsl:choose>

</xsl:template>

</xsl:stylesheet>

Ex2-Import-Script2.xsl

<?xml version="1.0" encoding="UTF-8"?>

<!-- This XSLT sample will convert the following email generated by the Email Service to hierarchical XML Subject: Request - Domain Password Reset Body: Department$IT Requester$Alan Taylor [email protected] -->

<xsl:stylesheet xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template name="SR_import" match="/">

<!-- Header XML of the service request. These are consistent across all types. -->

<BusinessObjectList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" SchemaVersion="1.0">

<BusinessObject Name="ServiceReq">

<Transaction>Insert</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="ServiceReqNumber"/>

</UniqueKey>

</UniqueKeyList>

<!-- First, we will load variables so we can use them easily later -->

<xsl:variable name="Subject" select="BusinessObjectList/BusinessObject/EmailMessage/Subject"/>

<xsl:variable name="Body" select="BusinessObjectList/BusinessObject/EmailMessage/Body"/>

<!-- Find the profile link RecID of the email sender, they will be the service requester-->

<xsl:variable name="ProfileRecId">

<xsl:for-each select="BusinessObjectList/BusinessObject/RelatedBusinessObjectList/RelatedBusinessObject/BusinessObject">

<xsl:choose>

<xsl:when test="@Name = 'Employee'">

<xsl:for-each select="./FieldList/Field">

<xsl:choose>

<xsl:when test="@Name = 'RecId'">

<xsl:value-of select="."/>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:variable>

<!-- Switch statement separates processing of each template type based on the email subject. In this example, we support only one request offering: Domain Password Reset. -->

<xsl:choose>

<!-- There will be a separate when section for each type of service request supported -->

<xsl:when test="contains($Subject,'Domain Password Reset')">

<!-- Now let's parse the body for the fields we want for a domain password reset -->

<!-- Department: -->

<xsl:variable name="dept" select="substring-after($Body,'Department$')"/>

<!-- Stop at the newline character -->

<!-- Requester: -->

<xsl:variable name="requestor" select="substring-after($Body,'Requester$')"/>

<!-- Email: -->

<xsl:variable name="email" select="substring-after($Body,'Email$')"/>

<!-- Fill in the necessary fields and related business objects for a domain password reset -->

<FieldList>

<Field Name="SvcReqTmplLink" Type="System.String">Domain Password Reset</Field>

<!-- Replace this subscription RecID with the valid one for your system: -->

<Field Name="SvcReqSubscLink_RecID" Type="System.String">BDF2D75B420C438E9468BC613E6AB369</Field>

<Field Name="Price">150.00</Field>

<Field Name="ProfileLink_RecID" Type="System.String">

<xsl:value-of select="$ProfileRecId"/>

</Field>

</FieldList>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">RequesterDepartment</Field>

<Field Name="ParameterValue" Type="System.String">

<xsl:choose>

<xsl:when test="contains($dept, ' ')">

<xsl:value-of select="substring-before($dept,' ')"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$dept"/>

</xsl:otherwise>

</xsl:choose>

</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">Requester</Field>

<Field Name="ParameterValue" Type="System.String">

<xsl:choose>

<xsl:when test="contains($requestor, ' ')">

<xsl:value-of select="substring-before($requestor,' ')"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$requestor"/>

</xsl:otherwise>

</xsl:choose>

</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">Email</Field>

<Field Name="ParameterValue" Type="System.String">

<xsl:choose>

<xsl:when test="contains($email, ' ')">

<xsl:value-of select="substring-before($email,' ')"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$email"/>

</xsl:otherwise>

</xsl:choose>

</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</xsl:when>

<!-- Next service request type would placed here in its own xsl:when block -->

<xsl:otherwise>

<other/>

</xsl:otherwise>

</xsl:choose>

<!-- Now close the service request XML -->

</BusinessObject>

</BusinessObjectList>

</xsl:template>

</xsl:stylesheet>

Ex2-Import-Final-Email.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" SchemaVersion="1.0">

<BusinessObject Name="Incident">

<Transaction>Insert</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="Subject" Type="System.String">RE: Test XML 3</Field>

<Field Name="Symptom">test XML Email </Field>

<Field Name="Service">Desktop Service</Field>

<Field Name="Category">Performance Issue</Field>

<Field Name="Owner">Quality Assurance</Field>

<Field Name="OwnerTeam">IT</Field>

<Field Name="Impact">Medium</Field>

<Field Name="Urgency">Medium</Field>

<Field Name="Source">Email</Field>

<Field Name="ProfileLink_Category">Employee</Field>

<Field Name="ProfileLink_RecID">3734B48625D043B0939456EBF5B07F43</Field>

</FieldList>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Employee">

<Transaction>None</Transaction>

<LinkTransaction>None</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="PrimaryEmail"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">3734B48625D043B0939456EBF5B07F43</Field>

<Field Name="PrimaryEmail">[email protected]</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

 

<RelatedBusinessObject Relationship="">

<BusinessObject Name="Journal.Email">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="RecId">68360EB2755F4B4084E45F65FCA73162</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

Ex2-Import-Final-Email2.xml

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" SchemaVersion="1.0">

<BusinessObject Name="ServiceReq">

<Transaction>Insert</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="ServiceReqNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="SvcReqTmplLink" Type="System.String">Domain Password Reset</Field>

<Field Name="SvcReqSubscLink_RecID" Type="System.String">BDF2D75B420C438E9468BC613E6AB369</Field>

<Field Name="Price">150.00</Field>

<Field Name="ProfileLink_RecID" Type="System.String">3734B48625D043B0939456EBF5B07F43</Field>

</FieldList>

 

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">RequesterDepartment</Field>

<Field Name="ParameterValue" Type="System.String">IT</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

 

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">Requester</Field>

<Field Name="ParameterValue" Type="System.String">Alan Taylor</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

 

<RelatedBusinessObject Relationship="ServiceReqContainsServiceReqParam">

<BusinessObject Name="ServiceReqParam">

<Transaction>Insert</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="RecId"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ParameterName" Type="System.String">Email</Field>

<Field Name="ParameterValue" Type="System.String">[email protected]</Field>

<Field Name="DisplayType" Type="System.String">text</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>


Was this article useful?